package org.cptz.game.controller;

import org.cptz.game.constant.EnumConst;
import org.cptz.game.dto.ResultDto;
import org.cptz.game.entity.Match;
import org.cptz.game.service.IMatchService;
import org.cptz.game.util.ReqUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * <p>
 * 局 前端控制器
 * </p>
 *
 * @author cpt.z
 * @since 2022-08-07
 */
@RestController
@RequestMapping("/match")
public class MatchController {
    @Autowired
    private IMatchService matchService;

    @PostMapping("/save")
    public ResultDto save(@RequestBody Match match) {
        matchService.save(match);
        return new ResultDto(EnumConst.RespCode.SUCCESS);
    }

    @PostMapping("/list")
    public ResultDto list(HttpServletRequest req) {
        return ResultDto.success(matchService.list(ReqUtil.resolve(req)));
    }
}
